<template>
	<view class="box">
		<view class="box-header">
			<image src="@/static/image/doctor.jpg" mode=""></image>
			<view class="header-text">
				<text style="font-weight: bold;">
					{{doctorInfo.realName}}
				</text>
				/
				<text>
					{{doctorInfo.occupationTitle}}
				</text>
			</view>
			<view class="header-text">
				<text>
					{{doctorInfo.hospital}}
				</text>
				/
				<text>
					{{doctorInfo.administrativeOffice}}
				</text>
			</view>
		</view>
		<view class="box-nav">
			<view class="nav-title">
				<view class="line"></view><text>医生简介</text>
			</view>
			<view class="nav-desc">
				{{doctorInfo.doctorIntroduction}}
			</view>
		</view>
		<view class="box-nav">
			<view class="nav-title">
				<view class="line"></view><text>专业擅长</text>
			</view>
			<view class="nav-desc">
				{{doctorInfo.personalExpertise}}
			</view>
		</view>
		<view class="box-nav">
			<view class="nav-title">
				<view class="line"></view>
				<text>出诊时间</text>
			</view>
			<view class="nav-choose">
				<view class="choose-box" v-for="item in doctorDutyList" :key="item">
					<view>{{item.dateTimeStr}} 星期{{item.weekNum===1?'一':item.weekNum===2?'二':item.weekNum===3?'三':item.weekNum===4?'四':item.weekNum===5?'五':item.weekNum===6?'六':'日'}}</view>
					<view v-for="item in item.timeVoList" :key="item">({{item.startTime}}~{{item.endTime}})</view>
					<u-button type="success" size="mini" style="width: 150rpx;" shape="circle"
						color="#54b6ab" @click="toNav(doctorId)">立即预约</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				doctorId:null,
				doctorInfo: {},
				doctorDutyList:[]
			};
		},
		onLoad(option) {
			this.doctorId = option.doctorId
			this.findDoctorDetail(this.doctorId)
		},
		methods: {
			//立即预约
			toNav(doctorId){
				uni.setStorageSync('doctorId',doctorId)
				uni.switchTab({
					url:'/pages/nav'
				})
			},
			async findDoctorDetail(doctorId) {
				if (!doctorId) {
					return false
				}
				const {
					data
				} = await uni.$http.post('/patient-doctor/findDoctorDetail?doctorId=' + doctorId)
				if (data.code === 200) {
					this.doctorInfo = data.data
					this.doctorDutyList = this.doctorInfo.doctorDutyList
				}
			}
		}
	}
</script>

<style lang="scss">
	.box {
		width: 100%;
		height: 100%;
		background-color: #f2f2f2;
		overflow: auto;

		.box-header {
			width: 100%;
			background-color: #54b6ab;
			padding: 20rpx;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-around;

			image {
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
			}

			.header-text {
				margin-top: 20rpx;
				color: #fff;
			}
		}

		.box-nav {
			width: 95%;
			margin: 20rpx auto 20rpx;
			padding: 20rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			background-color: #fff;

			.nav-title {
				width: 100%;
				display: flex;
				align-items: stretch;

				.line {
					width: 10rpx;
					background-color: #54b6ab;
					margin-right: 10rpx;
				}
			}

			.nav-desc {
				margin-top: 20rpx;
				width: 100%;
			}

			.nav-choose {
				margin-top: 20rpx;
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				align-items: center;

				.choose-box {
					width: 49%;
					padding: 20rpx;
					box-sizing: border-box;
					background-color: #f2f2f2;
					border-radius: 10rpx;
					margin-bottom: 20rpx;
					display: flex;
					flex-direction: column;
					align-items: center;

					view {
						margin-bottom: 10rpx;
						box-sizing: border-box;
					}
				}
			}
		}
	}
</style>